﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PlayerController : MonoBehaviour {

	
	public GameObject tb;
	public Text Count;
	public int score=10;

	private Rigidbody rb;
		// Use this for initialization
	void Start () {
		rb = GetComponent<Rigidbody> ();
		tb = GetComponent<GameObject> ();

	}
	
	// Update is called once per frame
	void Update () {
	
	}
	void FixedUpdate (){
		float moveH = Input.GetAxis("Horizontal");
		float moveV = Input.GetAxis ("Vertical");

		Vector3 direction = new Vector3 (moveH, 0, moveV);
		Vector3 force = direction * 5;
		rb.AddForce (force);
		Vector3 lan = new Vector3 (0, 0,0);
		lan = rb.transform.position;
		if (lan.x > 6)
			lan.x = 6;
		if (lan.x < -6)
			lan.x = -6;
		if (lan.z > 11)
			lan.z = 11;
		if (lan.z < -11)
			lan.z = -11;

		
		rb.transform.position = lan;
	}
	void OnTriggerEnter(Collider collider){
//		collider.gameObject.SetActive (false);
		Destroy (collider.gameObject);

		score += 10;
		Count.text=score+"";
	}
}
